package com.scnu.edu.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.scnu.edu.entity.Rating;
import com.scnu.edu.mapper.RatingMapper;
import com.scnu.edu.service.RatingService;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class RatingServiceImpl extends ServiceImpl<RatingMapper, Rating> implements RatingService {
    @Override
    public List<Rating> getRatingsByMovieId(Long movieId) {
        LambdaQueryWrapper<Rating> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(Rating::getMovieId, movieId)
                .orderByDesc(Rating::getCreateTime);
        return this.list(wrapper);
    }
}